package spring6_learn.transcation;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class TransAop {

    @Around("execution(* spring6_learn.transcation..*(..))")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable{
       try {
           //开启事务
           System.out.println("开启事务");
           //执行方法
           joinPoint.proceed();
           //提交事务
           System.out.println("提交事务");
       }catch (Exception e){
           System.out.println("回滚事务");
       }

    }
}
